package com.mybatis.study;

import java.util.List;

import com.mybatis.study.mapper.UserMapper;
import com.mybatis.study.model.User;
import com.mybatis.study.session.SqlSession;
import com.mybatis.study.session.SqlSessionFactory;

public class MybatisTest {

	private SqlSessionFactory sqlSessionFactory;

	public static void main(String[] args) {
		SqlSessionFactory factory = new SqlSessionFactory();
		SqlSession session = factory.getSession();
		System.out.println(session);
		UserMapper userMapper = session.getMapper(UserMapper.class);
		User user = userMapper.selectByPrimaryKey("1");
		System.out.println(user);
		System.out.println("______________________________");
		List<User> list = userMapper.selectAll(new User());
		if (null != list && list.size() > 0) {
			for (User user2 : list) {
				System.out.println(user2);
			}
		}
	}

	public void testAutoMapper() {
		SqlSessionFactory factory = new SqlSessionFactory();
		SqlSession session = factory.getSession();
		System.out.println(session);
	}

}
